package threading;
class Singleton {
    //唯一实例的本体
    private static Singleton instance = new Singleton();

    //获取到实例的方法
    public static Singleton getInstance() {
        return instance;
    }
    //禁止外部 new 实例
    private Singleton() {

    }
}
public class ThreadDemo17 {
    public static void main(String[] args) {
        //此时 s1 和 s2 是同一个对象
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
    }
}





